package UserUnit;

import java.util.*;

public class ImpNewsContent implements NewsContent {

    String paragraph;
    int idParagraph;
    int lastParagraph;
    ImpPhoto photo;
    List<Object> paraphoto = null;
    int cont = 0;

    public void setParagraph(String paragraph) {
        this.paragraph = paragraph;
        paraphoto.add(paragraph);


    }

    public void setPhoto(ImpPhoto photo) {
        this.photo = photo;
        cont++;
        paraphoto.add(photo);
    }

    public String getParagraph(int idParagraph) {
        this.idParagraph = idParagraph;
        if (paraphoto.get(idParagraph).equals(photo)) {
            String error = "Error!! There is a Photo in this position. Try another!!";
            return error;
        } else {
            return (String) paraphoto.get(idParagraph);
        }
    }

    public ImpPhoto getPhoto(int idparagraph) {
        this.idParagraph = idParagraph;
        int pos = idParagraph - cont;
        if (paraphoto.get(pos).equals(paragraph)) {
            return null;
        } else {
            return (ImpPhoto) paraphoto.get(pos);
        }
    }

    public void getLast() {
        paraphoto.lastIndexOf(paragraph);
    }
}
